package com.app.service.adapter;

import java.util.ArrayList;

import com.app.activity.R;
import com.app.data.InnItem;
import com.app.data.ScenicItem;
import com.app.service.adapter.HotelAdapter.HotelHandle;


import android.app.Activity;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

public class ScenicAdapter extends DataAdapter{

	private ArrayList<ScenicItem> scenics;
	public ScenicAdapter(Activity parentActivity ,ArrayList<ScenicItem> scenics) {
		super(parentActivity);
		this.scenics = scenics;
	}

	public ArrayList<ScenicItem> getScenics() {
		return scenics;
	}

	public void setScenics(ArrayList<ScenicItem> scenics) {
		this.scenics = scenics;
	}

	@Override
	public int getCount() {
		return scenics.size();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ScenicHandle handle;
		if(convertView == null)
		{
			//ScenicItem item = scenics.get(position);
			convertView = LayoutInflater.from(parentActivity).inflate(R.layout.scenic_list_item, null);
			handle = new ScenicHandle();
			handle.imgView = (ImageView)convertView.findViewById(R.id.imgScenicIcon);
			handle.nameView = (TextView)convertView.findViewById(R.id.tvSenicName);
			handle.priceView = (TextView)convertView.findViewById(R.id.tvSenicPrice);
			handle.contentView  = (TextView)convertView.findViewById(R.id.tvSenicIntro);
			handle.keyWordView = (TextView)convertView.findViewById(R.id.tvSenicSubject);
			convertView.setTag(handle);
		}else {
			handle = (ScenicHandle)convertView.getTag();
		}
		ScenicItem item = scenics.get(position);
		handle.imgView.setImageBitmap(item.getIconbitmap());
		handle.nameView.setText(item.getSenicName());
		handle.priceView.setText(item.getSenicPrice());
		handle.contentView.setText(item.getSenicIntro());
		handle.keyWordView.setText(item.getSenicSubject());
		return convertView;
	}
	
	class ScenicHandle
	{
		ImageView imgView;
		TextView nameView;
		TextView priceView;
		TextView contentView;
		TextView keyWordView;
	}
}
